package com;

/**
 * StringUtil
 * @author lichengdu
 * @createtime 2016年3月30日
 * @version 1.0
 */
public class StringUtil
{

	/**
	 * 驼峰命名
	 * @param arg0
	 * @return
	 */
	public static String toUpper(String str,String separator){
		String strName ="";
		String [] strs = str.split("["+separator+"]");
		for (String curStr : strs) {
			strName+=toUpperCase4Index(curStr);
		}
		return strName;
	}
	/**
	 * 拼接转小写
	 * @param arg0
	 * @return
	 */
	public static String toLower(String str,String separator){
		String strName ="";
		String [] strs = str.split("["+separator+"]");
		for (String curStr : strs) {
			strName+=toLowerCase4Index(curStr);
		}
		return strName;
	}
	/**
	 * 首字母转大写
	 * @param str
	 * @return
	 */
	public static String toUpperCase4Index(String str){
		
		char[] ch = str.toCharArray();
		for(int i=0; i<ch.length; i++){
			if(ch[i] >= 97 && ch[i] <= 122 ){
				ch[i]-=32;
				break;
			}			
		}
		return String.valueOf(ch);
	}
	
	/**
	 * 首字母转小写
	 * @param arg0
	 * @return
	 */
	public static String toLowerCase4Index(String arg0){
		
		char[] ch = arg0.toCharArray();
		for(int i=0; i<ch.length; i++){
			if(ch[i] >= 65 && ch[i] <= 90 ){
				ch[i]+=32;
				break;
			}			
		}
		return String.valueOf(ch);
	}
}
